package com.ssyt.ssh.sys.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.ssyt.ssh.common.BaseDao;
import com.ssyt.ssh.common.PageModel;
import com.ssyt.ssh.sys.dao.UserDao;
import com.ssyt.ssh.sys.entity.Log;
import com.ssyt.ssh.sys.entity.User;

@Repository
public class UserDaoImpl extends BaseDao<User, Integer> implements UserDao {

	public void addUser(User user) {
		save(user);
	}

	public User load(Integer id) {
		return load(id);
	}

	public void login() {
		PageModel<Object[]> pageModel = pageMultiPropertyByHql(1, 3,
				"FROM User u, Log l WHERE u.id=l.userId");
		List<Object[]> list = pageModel.getList();
		for (Object[] objects : list) {
			User user = (User) objects[0];
			Log log = (Log) objects[1];
			System.out.println(user);
			System.out.println(log);
		}
	}
}
